package com.gitee.wsl.security.rbac


interface RulePermissionScope: SubjectPermissionScope {

    fun user(vararg name: String)

    fun permissionOn(vararg subjectTreeName: String, permissionHandler: SubjectPermissionScope.()->Unit)
}

class RulePermissionScopeImp: SubjectPermissionScopeImp(), RulePermissionScope {
    var userList:List<String>?=null

    var permissionScopeMap = mutableMapOf <List<String>, SubjectPermissionScopeImp>()

    override fun user(vararg name: String) {
        userList=name.asList()
    }

    override fun permissionOn(
        vararg subjectTreeName: String,
        permissionHandler: SubjectPermissionScope.() -> Unit
    ) {
        val subjectPermissionScope= SubjectPermissionScopeImp()
        permissionHandler(subjectPermissionScope)
        permissionScopeMap[subjectTreeName.asList()] = subjectPermissionScope
    }

}